package com.weixing.mall.provider.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.weixing.mall.provider.mapper.PraiseLogMapper;
import com.weixing.mall.provider.model.domain.PraiseLog;
import com.weixing.mall.provider.service.IPraiseLogService;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 买家秀点赞记录表 服务实现类
 * </p>
 *
 * @author Small
 * @since 2020-04-16
 */
@Service
public class PraiseLogServiceImpl extends ServiceImpl<PraiseLogMapper, PraiseLog> implements IPraiseLogService {
    @Override
    public Boolean checkPraise(Long buyerShowId, Long memberId) {
        LambdaQueryWrapper<PraiseLog> logLambdaQueryWrapper = new LambdaQueryWrapper<>();
        logLambdaQueryWrapper.eq(PraiseLog::getBuyerShowId,buyerShowId).eq(PraiseLog::getMemberId,memberId);
        return count(logLambdaQueryWrapper) > 0 ? true : false;
    }

    @Override
    public void addPraiseLog(Long buyerShowId, Long memberId) {
        save(new PraiseLog().setBuyerShowId(buyerShowId).setMemberId(memberId));
    }

    @Override
    public void delPraiseLog(Long buyerShowId, Long memberId) {
       LambdaQueryWrapper<PraiseLog> logLambdaQueryWrapper = new LambdaQueryWrapper<>();
       logLambdaQueryWrapper.eq(PraiseLog::getBuyerShowId,buyerShowId).eq(PraiseLog::getMemberId,memberId);
       remove(logLambdaQueryWrapper);
    }
}
